package ${packageName}.controller;

import lombok.extern.slf4j.Slf4j;
import com.shopx.base.anno.ShopxParamAnno;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.shopx.base.controller.BaseController;
import javax.annotation.Resource;
import com.shopx.cmm.DTO.PageDTO;
import com.shopx.base.dto.Result;
import com.shopx.base.utils.ResultUtil;
import com.shopx.base.exception.ShopxException;
import ${packageName}.bean.${classInfo.className};
import ${packageName}.model.${classInfo.className}Model;
import ${packageName}.service.I${classInfo.className}Service;

import com.shopx.base.anno.RepearSubmitChkAnno;
import com.shopx.core.common.CommonConstant;

/**
 * TODO
 * @author ${authorName}
 * @className: ${classInfo.className}Controller
 * @date ${.now?string('yyyy-MM-dd')}
 */
@RestController
@Slf4j
@RequestMapping(value = "/${classInfo.className?uncap_first}")
public class ${classInfo.className}Controller extends BaseController{

	@Resource
    private I${classInfo.className}Service ${classInfo.className?uncap_first}Service;

	@PostMapping(value = "/queryPageList")
@ShopxParamAnno
@ShopxCheckParamAnno
 public Result<PageDTO> queryPageList(@RequestBody ${classInfo.className}Model ${classInfo.className?uncap_first}) throws ShopxException{
		PageDTO<${classInfo.className}Model> pageDTO = ${classInfo.className?uncap_first}Service.getListPage(${classInfo.className?uncap_first});
  		return ResultUtil.ok(pageDTO);
	}

	@PostMapping(value = "/insertOne")
	@RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
		@ShopxParamAnno
public Result<Integer> insertOne(@RequestBody ${classInfo.className} ${classInfo.className?uncap_first}) throws ShopxException {
		int result = ${classInfo.className?uncap_first}Service.insertSelective(${classInfo.className?uncap_first});
      	return ResultUtil.ok(result);
	}

	@PostMapping(value = "/updateOne")
	@RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
			@ShopxParamAnno
public Result<Integer> updateOne(@RequestBody ${classInfo.className} ${classInfo.className?uncap_first}) throws ShopxException {
		int result = ${classInfo.className?uncap_first}Service.updateByPrimaryKeySelective(${classInfo.className?uncap_first});
        return ResultUtil.ok(result);
	}

	@PostMapping(value = "/queryOneByPrimaryKey")
				public Result<${classInfo.className}Model> queryOneByPrimaryKey(@RequestBody ${classInfo.className} ${classInfo.className?uncap_first}) throws ShopxException {
		${classInfo.className}Model result = ${classInfo.className?uncap_first}Service.selectByPrimaryKey(${classInfo.className?uncap_first});
		return ResultUtil.ok(result);
	}

	/*@PostMapping(value = "/deleteChecked")
	@RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
					@ShopxParamAnno
public Result<Integer> deleteChecked(@RequestBody ${classInfo.className} ${classInfo.className?uncap_first}) throws ShopxException {
		int result = ${classInfo.className?uncap_first}Service.deleteByPrimaryKey(${classInfo.className?uncap_first});
		return ResultUtil.ok(result);
	}*/
}
